<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-on</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<h1>v-on:为元素绑定事件</h1>
<div id="app">
    <button onclick="console.log('onclick')">onclick</button>
    <button v-on:click="log('v-on:click')">v-on:click</button>
    <button @click="log('@click')">@click</button>
    <input type="text" @keyup.enter="log('@keyup.enter回车触发')">
    <br>
    <div>
        <button @click="sub">-</button>
        <span>{{count}}</span>
        <button @click="add">+</button>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data:{
            count: 0
        },
        methods: { //方法
            log: function (msg) {
                console.log(msg)
            },
            sub: function () {
                this.count--
            },
            add: function () {
                this.count++
            }
        }
    })
</script>
</body>
</html>